package su.Ner;

import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.HashMap;
import java.util.HashSet;

public class Names {

	public HashMap<String,Integer> personNames=new HashMap<String,Integer>();
	public HashMap<String,Integer> locationNames=new HashMap<String,Integer>();
	public HashMap<String,Integer> organizationNames=new HashMap<String,Integer>();
	public HashMap<String,Integer> titleNames=new HashMap<String,Integer>();
	
	
	public Names(String root) throws IOException {
		// get 4 hashsets
		BufferedReader br=new BufferedReader(new FileReader(root+"names/person.txt"));
		int i=0;
		while(true){
			String line=br.readLine();
			if(null==line || line.equals("")) break;
			if(line.length()>2)
			personNames.put(line.toLowerCase(),i++);
		}
		br.close();
		br=new BufferedReader(new FileReader(root+"names/location.txt"));
		i=0;
		while(true){
			String line=br.readLine();
			if(null==line || line.equals("")) break;
			if(line.length()>2)
			locationNames.put(line.toLowerCase(),i++);
		}
		br.close();
		br=new BufferedReader(new FileReader(root+"names/organization.txt"));
		i=0;
		while(true){
			String line=br.readLine();
			if(null==line || line.equals("")) break;
			if(line.length()>2)
			//organizationNames.put(line.toLowerCase(),i++);
				organizationNames.put(line,i++);
		}
		br.close();
		br=new BufferedReader(new FileReader(root+"names/title.txt"));
		i=0;
		while(true){
			String line=br.readLine();
			if(null==line || line.equals("")) break;
			if(line.length()>2)
			titleNames.put(line.toLowerCase(),i++);
		}
		br.close();
	}
}
